package likou;

import java.util.Arrays;

/**
 * @author: Tangxz
 * @email: 1171702529@qq.com
 * @cate: 2021/11/17 09:12
 */
public class _318 {
    public static void main(String[] args) {
        _318 o = new _318();
        System.out.println(o.maxProduct(new String[]{"abcw","baz","foo","bar","xtfn","abcdef"}));
    }
    public int maxProduct(String[] words) {
        int[] nums = new int[words.length];
        Arrays.sort(words,(s1, s2)-> s2.length()-s1.length());
        for(int i=0;i<words.length;i++){
            char[] cs = words[i].toCharArray();
            for(char c:cs){
                nums[i] |= (1<<(c-'a'));
            }
        }
        int max = 0;
        for(int i=0;i<words.length;i++){
            for(int j=i+1;j<words.length;j++){
                if((nums[i]&nums[j])==0) {
                    max = Math.max(max,words[i].length()*words[j].length());
                }
            }
        }
        return max;
    }
}
